<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>对象继承</title>
    </head>
    <body></body>
    <script type="text/javascript">
        //构造函数的继承
        //计算机
        function Computer(brand, price){
            this.brand = brand;
            this.price = price;
        }

        //添加方法
        Computer.prototype.program = function(){
            console.log('编程....');
        }

        //笔记本电脑
        function NoteBook(brand, price, screen, storage){
            //初始化实例对象
            Computer.call(this, brand, price);
            this.screen = screen;
            this.storage = storage;
        }

        //实现继承
        NoteBook.prototype = new Computer();
        NoteBook.prototype.constructor = NoteBook;

        //添加子类的方法
        NoteBook.prototype.watchTv = function(){
            console.log('看电视...');
        }

        NoteBook.prototype.paomian = function(){
            console.log('泡面....');
        }

        //实例化对象
        let notebook = new NoteBook('宏碁', 4100, '13.3inch', '360G');

        // console.log(notebook);
        notebook.program();
        

    </script>
</html>
